#if !defined(_AFIXARRAY_H_)
#define _AFIXARRAY_H_

#include "AObject.h"

template<class _T>
class CAFixArray 
{
protected:
	_T*	_p;
	size_t _c;
public:
	CAFixArray(void)
	{
		_p = null;
		_c = 0;
	}

	CAFixArray(int size)
	{
		init(size);
	}

	void clear()
	{
		if (null != _p)
		{
			delete [] _p;
			_p = null;
			_c = 0;
		}
	}

	void init(int size)
	{
		GUARD_FUNCTION();
		clear();
		if (size)
			_p = new _T[size];
		else
			_p = null;
		_c = size;
	}

	virtual ~CAFixArray(void)
	{
		clear();
	}

	inline _T* ptr() { return _p; }
	inline size_t count() const { return _c; }

	_T& operator[](int index)
	{
		return _p[index];
	}

	const _T& operator[](int index) const
	{
		return _p[index];
	}
};

#endif //_AFIXARRAY_H_
